package com.example.tutk;

import android.app.Application;
import android.util.Log;

import com.tutk.IOTC.IOTCAPIs;

/**
 * Created by 李文旭 on 2018/9/4.
 */

public class MainApplication extends Application {
    @Override
    public void onCreate()
    {
        super.onCreate();
        // 启动线程执行下载任务
        int ret = IOTCAPIs.IOTC_Initialize2(0);
        int sessionId = IOTCAPIs.IOTC_Connect_ByUID_Parallel("GV4GRAS1S2XJY3F1111A", IOTCAPIs.IOTC_Get_SessionID());//连接获取sessionId


        IOTCAPIs.IOTC_Session_Close(sessionId);//关闭
        IOTCAPIs.IOTC_DeInitialize();//释放资源
        try {
            check(ret);
            check(sessionId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        Log.d("para", ret + " " + IOTCAPIs.IOTC_Get_SessionID() + "  " + sessionId + IOTCAPIs.IOTC_Session_Get_Free_Channel(sessionId));
    }
    public void check(int ready) throws Exception {
        if(ready!=0)
        {
            throw new Exception("tutk api not return 0 but returned "+ready);
        }
    }
}
